using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace RootobjectName
{
    public class Rootobject
    {
        public string code { get; set; }
        public string updateTime { get; set; }
        public string fxLink { get; set; }
        public Now now { get; set; }
        public Refer refer { get; set; }
        public Daily[] daily { get; set; }
        // 添加 locationId 字段
        public Location[] location { get; set; }
        //获取第一个id
        public string FirstLocationId
        {
            get
            {
                return location != null && location.Length > 0 ? location[0].id : null;
            }
        }
    }
    public class Location
    {
        public string id { get; set; }
    }

    public class Refer
    {
        public string[] sources { get; set; }
        public string[] license { get; set; }
    }
    public class Daily
    {
        public string date { get; set; }
        public string iconDay { get; set; }
        public string tempMax { get; set; }
        public string tempMin { get; set; }
        public string tmp1 { get; set; }
        public string textDay { get; set; }
        public string textNight { get; set; }
        public string windDirDay { get; set; }
        public string windDirNight { get; set; }
        public string windSpeedDay { get; set; }
        public string windSpeedNight { get; set; }

        // 添加 toString 方法
        public override string ToString()
        {
            return $"Date: {date}\n" +
                   $"IconDay: {iconDay}\n" +
                   $"Max Temp: {tempMax} °C\n" +
                   $"Min Temp: {tempMin} °C\n" +
                   $"Min Tmp1: {tmp1} °C\n" +
                   $"Day Weather: {textDay}\n" +
                   $"Night Weather: {textNight}\n" +
                   $"Day Wind Direction: {windDirDay}\n" +
                   $"Night Wind Direction: {windDirNight}\n" +
                   $"Day Wind Speed: {windSpeedDay} km/h\n" +
                   $"Night Wind Speed: {windSpeedNight} km/h\n";
        }
    }
    public class Now
    {
        public string obsTime { get; set; }
        public string temp { get; set; }
        public string feelsLike { get; set; }
        
        public string text { get; set; }
        public string wind360 { get; set; }
        public string windDir { get; set; }
        public string windScale { get; set; }
        public string windSpeed { get; set; }
        public string humidity { get; set; }
        public string precip { get; set; }
        public string pressure { get; set; }
        public string vis { get; set; }
        public string cloud { get; set; }
        public string cond_code { get; set; }
        public string cond_txt { get; set; }
        public string icon { get; set; }
        public string dew { get; set; }

        //编写toString方法
        public override string ToString()
        {
            return $"Observation Time: {obsTime}\n" +
                   $"Temperature: {temp} °C\n" +
                   $"Feels Like: {feelsLike} °C\n" +
                   $"Weather: {text}\n" +
                   $"Wind Direction: {windDir} ({wind360}°)\n" +
                   $"Wind Speed: {windSpeed} km/h\n" +
                   $"Humidity: {humidity}%\n" +
                   $"Pressure: {pressure} hPa\n" +
                   $"Visibility: {vis} km\n" +
                   $"Cloud: {cloud}%\n" +
                   $"Cond_code: {cond_code}%\n" +
                   $"Cond_txt: {cond_txt}%\n" +
                   $"Icon: {icon}%\n" +
                   $"Dew Point: {dew} °C";
        }
 

    }

}
